<html>
<head>
  <script src="../../resources/run-after-layout-and-paint.js"></script>
  <style>
    #clipper {
      width: 550px;
      height: 550px;
      overflow:hidden;
    }

    #trigger {
      /* Only overlap with the contents element, not the stretch element */
      will-change:transform;
      position: absolute;
      top: 0px;
      left: 0px;
      width: 500px;
      height: 200px;
    }

    #container {
      /* Force compositing for this layer if any children get composited */
      transform:translate(0px, 1px);
    }

    #negative {
      /* Trigger foreground layer from container */
      z-index: -1;
      position: absolute;
    }

    #contents {
      /* foreground layer contents */
      width: 550px;
      height: 550px;
      background-color: green;
    }

    /* Move this element to stretch container to have a negative offset */
    #stretch {
      position: absolute;
      background-color: blue;
      top: 200px;
      left: -200px;
      width: 50px;
      height: 50px;
    }

  </style>
  <script>
    function doTest()
    {
      runAfterLayoutAndPaint(function() {
        document.getElementById("stretch").style.left = "-100px";
      }, true);
    }

    window.addEventListener('load', doTest, false);
  </script>
</head>
<body>
  <div id="trigger"></div>
  <div id="clipper">
    <div id="container">
      <img id="contents">
      <div id="stretch"></div>
      <div id="negative"></div>
    </div>
  </div>
</body>
